package com.thon.service.user.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.thon.dao.user.PresentDao;
import com.thon.dao.util.Page;
import com.thon.entity.project.ProjectSupport;
import com.thon.entity.user.Message;
import com.thon.entity.user.Present;
import com.thon.entity.user.User;
import com.thon.service.user.PresentService;

@Service
@Transactional
public class PresentServiceImpl implements PresentService{
	
	@Autowired
	private PresentDao presentDao;

	@Override
	public void save(Present present) {
		presentDao.save(present);
	}

	@Override
	public void update(Present present) {
		presentDao.update(present);
	}

	@Override
	public Page<Present> findAllByPhone(String loginName, int pageNo,
			int pageSize) {
		Page<Present> page = new Page<Present>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		return presentDao.findAllByPhone(page, loginName);
	}

	@Override
	public Present findOne(Integer presentId) {
		return presentDao.get(presentId.intValue());
	}

	@Override
	public Page<Present> findPrsentByStatus(String loginName, int status, int pageNo, int pageSize) {
		// TODO Auto-generated method stub
		Page<Present> page = new Page<Present>();
		page.setPageNo(pageNo);
		page.setPageSize(pageSize);
		return presentDao.findPresentByStatus(page, loginName, status);
	}

	@Override
	public void sendMail(ProjectSupport newProjectSupport, User oldUser,User newUser) {}

	@Override
	public void addUser(User oldUser, ProjectSupport projectSupport) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void del(int id) {
		presentDao.delete(id);
	}

	@Override
	public Present getPresent(int id) {
		
		return presentDao.get(id);
	}

	@Override
	public Long countPresent(String loginName) {
		
		return presentDao.countPresent(loginName);
	}

	@Override
	public List<Present> listPresentByPhone(String loginName) {
		
		return presentDao.listPresentByPhone(loginName);
	}

}
